﻿namespace WebPacker.Tests.Helpers
{
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Text;
	using NUnit.Framework;
	using WebPacker.Helpers;

	[TestFixture]
	public class HashHelperTest
	{
		[Test]
		public void ComputeMd5HashStringTest()
		{
			var expected = "fc3ff98e8c6a0d3087d515c0473f8677";
			var actual = HashHelper.ComputeMd5HashString("hello world!");
			Assert.AreEqual(expected, actual);
		}

		[Test]
		public void ComputeMd5HashStringWithEncodingTest()
		{
			var expected = "f8233fed3b836a67d5e7e4c4775e5836";
			var actual = HashHelper.ComputeMd5HashString("хэллоу, ворлд!", Encoding.GetEncoding(1251));
			Assert.AreEqual(expected, actual);
		}

		[Test]
		public void ComputeMd5HashStringEmptyTest()
		{
			Assert.IsEmpty(HashHelper.ComputeMd5HashString(string.Empty));
		}

		[Test]
		public void BytesToStringTest()
		{
			var expected = "0001020364c8ff";
			var actual = HashHelper.ToString(new byte[] { 0, 1, 2, 3, 100, 200, 255 });
			Assert.AreEqual(expected, actual);
		}
	}
}
